<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<HeadNav titleName="" :topheight="navBarHeight"></HeadNav>
		
		<view class="main">
			<view class="main-tit">填写助记词</view>
			
			<view class="word-wrap">
				<textarea name="" id="" v-model="words"></textarea>
			</view>
			
			<view class="footer">
				<view @click="confim">下一步</view>
			</view>
			
			
		</view>
	</view>
</template>

<script>
	import { throttle } from '@/utils/common.js'
	import HeadNav from "@/components/HeadNav"
	import navBarMixin from '@/mixin/navBarMixin.js'
	import { worldLoginApi , forgetCheckPsdApi } from '@/api/api.js'
	export default {
		data() {
			return {
				words: ''
			}
		},
		components: {
			HeadNav
		},
		mixins: [navBarMixin],
		methods: {
			back() {
				uni.navigateBack()
			},
			confim() {
				
				const wordsObj = {
					type: 1,
					words: this.words.replace(/ /g,',')
				}
				
				throttle(async() => {
					if(!this.words) {
						uni.showToast({
							title: '请填写助记词',
							icon: 'none'
						})
						return
					}
					
					const res = await forgetCheckPsdApi({
						words: this.words.replace(/ /g,',')
					})
					
					if(!res.code) {
						uni.showToast({
							title: '校验成功',
							icon: 'none'
						})
						
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/login/setPassWord?data=' + JSON.stringify(wordsObj)
							})
						},2500)
						
					}else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
					
				},4000)
			
			}
		},
		onLoad() {
		}
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		overflow: hidden;
		min-height: 100vh;
		background: #fff;
		box-sizing: border-box;
		
		.back {
			image {
				width: 20rpx;
				height: 37rpx;
			}
		}
		
		.head {
			position: fixed;
			top: 0;
			z-index: 1;
			width: 100%;
			background: #fff;
		
			.head-np {
				display: flex;
				align-items: center;
				width: 100%;
				height: 96rpx;
				padding: 0 30rpx;
				box-sizing: border-box;
			}
		}
		
		.main {
			margin-top: 126rpx;
			padding: 0 30rpx;
			
			.main-tit {
				font-size: 48rpx;
				color: #333;
				font-weight: bold;
				text-align: center;
			}
			
			.word-wrap {
				min-height: 288rpx;
				margin-top: 80rpx;
				padding: 14rpx;
				background: #F8F8F8;
				border-radius: 10rpx;
				textarea {
					width: 100%;
					height: 326rpx;
				}
			}
			
			.footer {
				padding: 0 35rpx;
				margin-top: 140rpx;
				&>view {
					line-height: 80rpx;
					text-align: center;
					color: #fff;
					background: $theme-color-a;
					border-radius: 40rpx;
				}
			}
		}
	}
</style>